package com.clubs.coding.config;

import com.clubs.coding.filter.UserFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述：     User过滤器的配置
 */
@Configuration
public class UserFilterConfig {

    @Bean
    public UserFilter UserFilter() {
        return new UserFilter();
    }

    @Bean(name = "UserFilterConf")//定义出去可以拿到
    public FilterRegistrationBean UserFilterConfig() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(UserFilter());
      filterRegistrationBean.addUrlPatterns("/admin/*");//控制路径为Post开头所以
        filterRegistrationBean.addInitParameter("excludedUris","/admin/login,/admin/getCode");
//        filterRegistrationBean.addInitParameter("excludedUris","/admin/getCode");
        filterRegistrationBean.setName("UserFilterConf");
        return filterRegistrationBean;
    }
}
